﻿using System.IO;
using System.Net;
using System.Text;

namespace IceDog.Lib.IceDogHttp
{
    class IceDogNetwork
    {
        public static StringBuilder Get(string url)
        {
            var content = string.Empty;
            if (string.IsNullOrEmpty(url))
            {
                url = "http://localhost";
            }
            //创建的是http请求，所以要转换一下，因为网络请求还有如FTP请求等等，有差异性
            var req = (HttpWebRequest)WebRequest.Create(url);
            var res = (HttpWebResponse)req.GetResponse();
            var steam = res.GetResponseStream();
            if (steam != null)
            {
                var reader = new StreamReader(steam);
                content = reader.ReadToEnd();
            }
            return new StringBuilder(content);
        }
    }
}
